<?php
  session_start();
  if(!isset($_SESSION['id'])) {
    header("location:logout.php");
  }
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="assets/ico/favicon.png">

    <title>Sample Admin Panel</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.css" rel="stylesheet">

    <link rel="stylesheet" href="font-awesome/css/font-awesome.css">

    <!-- Custom styles for this template -->
    <link href="signin.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="assets/js/html5shiv.js"></script>
      <script src="assets/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
<?php
//pr($_SERVER);
$file_path = $_SERVER['REQUEST_URI'];
$file_path = explode('/',$file_path);
$file_name = array_pop($file_path);
//vd($file_name);

$isHomeActive = '';
$isUserActive = ($file_name == 'show_all_users.php')?'active' :'' ;
$isProductActive = ($file_name == 'show_all_products.php')?'active' :'' ;

?>
<div class="navbar navbar-default navbar-fixed-top" >
      <div class="container">
        <div class="navbar-header">
          <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a href="#" class="navbar-brand">Project name</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="<?=$isHomeActive?>"><a href="#">Home</a></li>
            <li class="<?=$isUserActive?>"><a  href="show_all_users.php">All Users</a></li>
            <li class="<?=$isProductActive?>"><a  href="show_all_products.php">All Products</a></li>
            <li class="dropdown">
              <a data-toggle="dropdown" class="dropdown-toggle" href="#">Add New <b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="register.php">User</a></li>
                <li><a href="add_product.php">Product</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li class="dropdown-header">Nav header</li>
                <li><a href="#">Separated link</a></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">

            <li style="width:200px;padding-bottom: 15px;
    padding-top: 15px;line-height: 20px;">Welcome,&nbsp;<?=$_SESSION['name']?></li>
            <li class="active"><a href="logout.php">Logout</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
 </div> <!-- End navbar navbar-default navbar-fixed-top-->
